package com.own.toyexchange;

/*
 * 介绍自己发布的玩具详情的activity
 */

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

import com.bjtu.toyexchange.R;
import com.item.toyexchange.ToyInfoActivity;

public class OwnToyInfo extends Activity {
	private Button mod, del, fanhui;
	String name, deg, state, detail, username;
	TextView nameET, degET, stateET, detailET;
	ImageView pic;
	
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.own_toy_info);
		
		deg = "九成新";
		
		//得到玩具的名字
		Intent intent = this.getIntent();
		name = intent.getStringExtra("title");
		
		//得到玩具的详细描述，即玩具介绍
		detail = intent.getStringExtra("content");
		
		//得到用户名
		username = intent.getStringExtra("username");
		
		//玩具的照片
		pic = (ImageView)findViewById(R.id.own_toy_ima);
		
		//设置几个Textview的值
		//名字
		nameET = (TextView)findViewById(R.id.own_toy_name);
		nameET.setText(name);
		//新旧程度
		degET = (TextView)findViewById(R.id.own_toy_deg);
		degET.setText(deg);
		//交换状态
		stateET = (TextView)findViewById(R.id.own_toy_sta);
		stateET.setText(state);
		//详细描述
		detailET = (TextView)findViewById(R.id.own_toy_det);
		detailET.setText(detail);
		
	    //修改玩具信息的按钮
		mod = (Button)findViewById(R.id.mod_own_toy);
		mod.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				//传递玩具的名称、新旧程度、详细描述到修改玩具界面
				Intent intent = new Intent();
				intent.putExtra("name", name);
				intent.putExtra("deg", deg);
				intent.putExtra("detail", detail);
				intent.putExtra("username", username);
				intent.setClass(OwnToyInfo.this, ModOwnToyInfo.class);
				OwnToyInfo.this.startActivity(intent);
			}
		});
		
		//删除玩具信息的按钮
		del = (Button)findViewById(R.id.del_own_toy);
		del.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				Toast.makeText(OwnToyInfo.this, "删除...", 200).show();
			}
		});
		
		//返回的按钮
		fanhui = (Button)findViewById(R.id.btnbackowntoy);
		fanhui.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				OwnToyInfo.this.finish();
			}
		});
	}
}
